<template>
    <div>
        <el-container style="height: 100vh;">
  <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
    <el-menu router unique-opened default-active="$route.path">
      <el-submenu index="1">
        <template slot="title"><i class="el-icon-message"></i>内容管理</template>
        <el-menu-item-group>
          <template slot="title">区域</template>
          <el-menu-item index="/categories/create">新建区域</el-menu-item>
          <el-menu-item index="/categories/list">区域列表</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group>
          <template slot="title">登记</template>
          <el-menu-item index="/Item/create">登记审批</el-menu-item>
          <el-menu-item index="/Item/list">以通过列表</el-menu-item>
          <el-menu-item index="/Item/console">不通过列表</el-menu-item>
        </el-menu-item-group>
       <el-menu-item-group>
          <template slot="title">上传</template>
          <el-menu-item index="/Hero/create">上传审批</el-menu-item>
          <el-menu-item index="/Hero/list">以通过列表</el-menu-item>
          <el-menu-item index="/Hero/lists">不通过列表</el-menu-item>
        </el-menu-item-group>
           <el-menu-item-group>
          <template slot="title">公告</template>
          <el-menu-item index="/Article/create">新建公告</el-menu-item>
          <el-menu-item index="/Article/list">公告列表</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title"><i class="el-icon-message"></i>运营管理</template>
        <el-menu-item-group>
          <template slot="title">广告位</template>
          <el-menu-item index="/Advertise/create">新建广告</el-menu-item>
          <el-menu-item index="/Advertise/list">广告列表</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
       <el-submenu index="3">
        <template slot="title"><i class="el-icon-message"></i>系统设置</template>
        <!-- <el-menu-item-group>
          <template slot="title">分类</template>
          <el-menu-item index="/categories/create">新建分类</el-menu-item>
          <el-menu-item index="/categories/list">分类列表</el-menu-item>
        </el-menu-item-group> -->
        <el-menu-item-group>
          <template slot="title">管理员管理</template>
          <el-menu-item index="/Adminuser/create">新建管理员</el-menu-item>
          <el-menu-item index="/Adminuser/list">管理员列表</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </el-aside>

  <el-container>
    <el-header style="text-align: right; font-size: 12px">
      <el-button class="login-button" @click="consolelogin">退出登录</el-button>
      <span>欢迎回来：{{name}}</span>
    </el-header>

    <el-main>
      <router-view :key="$route.path"></router-view>
    </el-main>
  </el-container>
</el-container>
    </div>
</template>

<script>
  export default {
    data() {
      return {
        name:''
      }
    },
    methods:{
      async getData() {
         const id = localStorage.getItem('id')
         const res = await this.$http.get(`login/${id}`)
         this.name = res.data.username
         console.log(res,'zhu');
      },
      consolelogin() {
        localStorage.removeItem('token')
        this.$router.push("/login");
        this.getData()
      }
    },
    created() {
      this.getData()
    }
  };
</script>

<style scoped>
  .el-header {
    background-color: #B3C0D1;
    color: #333;
    line-height: 60px;
  }

  .login-button {
  }

  .el-aside {
    color: #333;
  }
</style>
